package com.aifund.app.controller;

import com.aifund.app.entity.vo.home.HomeDataVo;
import com.aifund.app.service.HomeService;
import com.aifund.common.result.ResultBody;
import com.aifund.common.util.JwtUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * 首页
 */
@RestController
@RequestMapping("/api/home")
@Api(tags = "首页")
public class HomeController {

    @Autowired
    HomeService homeService;
    @Autowired
    JwtUtil jwtUtil;

    Logger logger = LoggerFactory.getLogger(HomeController.class);



    /**
     * 获取首页数据
     * @return
     */
    @ApiOperation(value = "获取首页数据")
    @GetMapping("/homeData")
    public ResultBody<HomeDataVo> homeData(HttpServletRequest request){
        Long userId = jwtUtil.getUserId(request);
        logger.info("用户{}获取首页数据",userId);
        return homeService.getHomeData(userId);
    }


}
